<template>
	<!-- 社团 -->
	<view>
		<view class="club-item" v-for="(item,i) in clubList" :key="i" @click="toClubDetail">
			<!-- 左侧图片 -->
			<view class="club-item-left">
				<image :src="imgUrl+item.association_image" mode="aspectFill" class="club-item-left-image" @error="imgError(i)"></image>
			</view>
			<!-- 中间信息 -->
			<view class="club-item-center">
				<!-- 头部 -->
				<view class="club-item-center-top">
					<view class="club-item-center-top-title">{{item.association_name}}
					</view>
					<view class="club-item-center-top-type">{{item.type}}</view>
				</view>
				<!-- 底部 -->
				<view class="club-item-center-bottom">
					<view class="club-item-center-bottom-number">
						<uni-icons class="setIcon" type="staff-filled" size="24" color="#3872c0"></uni-icons>
						:{{item.total_member}}
					</view>
					<view class="club-item-center-bottom-ranking">
						<uni-icons class="setIcon" type="staff-filled" size="24" color="#3872c0"></uni-icons>
						:{{item.total_activity}}
					</view>
				</view>
			</view>
			<!-- 右侧加入按钮 -->
			<view class="club-item-right">
				<button class="club-item-right-btn" :class="btnText=='已入会'?'greenStatus':''">{{btnText}}</button>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/config'
	export default {
		props: {
			clubList: {
				type: Array
			},
			btnText:{
				type:String
			}
		},
		data() {
			return {
				clubData:this.clubList,
				imgUrl: config.imgUrl
			}
		},

		methods: {
			// 跳转社团详情
			toClubDetail() {
				uni.navigateTo({
					url: `/subPackages/MyClub/ClubDetail/index?clubId=${this.clubData.association_id}`
				})
			},
			imgError(i){
				console.log(i);
				console.log(this.clubData[i],"图片错误出力");
			}
		},
		onLoad() {},
		onShow() {
			console.log('这里先获取社团信息，占位');
		}
	}
</script>

<style lang="scss">
	// 设置图标对齐
	.setIcon {
		vertical-align: sub;
	}

	.club-item {
		display: flex;
		justify-content: space-around;
		align-items: center;
		border: 2rpx solid #BBBBBB;
		padding: 20rpx;

		.club-item-left {
			width: 150rpx;
			height: 150rpx;
			border-radius: 10%;
			border: 1px solid pink;

			.club-item-left-image {
				width: 100%;
				height: 100%;
				border-radius: 10%;
			}
		}

		.club-item-center {
			width: 290rpx;
			height: 140rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.club-item-center-top,
			.club-item-center-bottom {
				display: flex;
				justify-content: space-between;
			}

			.club-item-center-top {
				height: 40rpx;

				.club-item-center-top-title {
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					color: #3872C0;
				}

				.club-item-center-top-type {
					width: 92rpx;
					text-align: center;
					color: #101010;
					background-color: #11D183;
					border-radius: 46rpx;
				}
			}
		}

		.club-item-right {
			width: 160rpx;
			height: 60rpx;

			.club-item-right-btn {
				width: 160rpx;
				height: 60rpx;
				font-size: 28rpx;
				color: #fff;
				background-color: #4095E5;
				text-align: center;
				line-height: 60rpx;
			}
			.greenStatus{
				background-color: #2cc04d;
			}
		}
	}
</style>
